package com.lxj.passkeep.controller;

import com.lxj.passkeep.common.result.ResponseResult;
import com.lxj.passkeep.dto.FormDataDto;
import com.lxj.passkeep.service.FormDataService;
import com.lxj.passkeep.vo.FormDataVo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/formData")
public class FormController {

    @Resource
    private FormDataService formDataService;

    // TODO 根据用户名（id）去查询表
    @GetMapping("/selectAll")
    public ResponseResult<List<FormDataVo>> selectAll(){
        List<FormDataVo> resultList=formDataService.selectAll();
        return ResponseResult.success(resultList);
    }

    @PostMapping("/insert")
    public ResponseResult insert(@RequestBody FormDataDto formDataDto){
        formDataService.insert(formDataDto);
        return ResponseResult.success();
    }
    @GetMapping("/getDataById")
    public ResponseResult<FormDataVo> getDataById(@RequestParam("id") Integer id){
        FormDataVo formDataVo=formDataService.getDataById(id);
        return ResponseResult.success(formDataVo);
    }
}
